import { FlatCompat } from '@eslint/eslintrc';
import path from 'path';
import { fileURLToPath } from 'url';

import babelParser from '@babel/eslint-parser';
import tsParser from '@typescript-eslint/parser';
import vueParser from 'vue-eslint-parser';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
    baseDirectory: __dirname,
});

export default [
    ...compat.extends('alloy', 'alloy/vue', 'alloy/typescript'),
    {
        languageOptions: {
            parser: vueParser,
            parserOptions: {
                parser: {
                    js: babelParser,
                    jsx: babelParser,
                    ts: tsParser,
                    tsx: tsParser,
                },
                sourceType: 'module',
            },
        },
    },
    {
        files: ['src/**/*.js', 'src/**/*.jsx'],
        languageOptions: {
            parser: babelParser,
        },
    },
    {
        files: ['src/**/*.ts', 'src/**/*.tsx'],
        languageOptions: {
            parser: tsParser,
        },
    },
    {
        rules: {
            complexity: 0,
        },
    },
];
